package oracle.apps.financials.collection.fragment;

import oracle.apps.financials.collection.activity.ListOfValueActivity;
import oracle.apps.financials.collection.activity.MainActivity;
import oracle.apps.financials.collection.activity.TopDelinquentCustomerActivity;
import android.app.Fragment;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageButton;

import com.cyrilmottier.android.greendroid.R;

public class MenuBarFragment extends Fragment {

	protected ImageButton homeButton;
	protected ImageButton topDelinquentCustomerButton;
	protected ImageButton collectorButton;
	protected ImageButton profileButton;
	protected ImageButton helpButton;

	@Override
	public void onActivityCreated(Bundle savedInstanceState) {
		super.onActivityCreated(savedInstanceState);

		homeButton = (ImageButton) getActivity().findViewById(R.id.home_item);
		homeButton.setImageResource(R.drawable.gd_action_bar_home);

		getActivity();
		homeButton.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent intent = new Intent(getActivity(), MainActivity.class);
				if (intent != null) {
					startActivity(intent);
				}
			}

		});
		topDelinquentCustomerButton = (ImageButton) getActivity().findViewById(R.id.top_deplinquent_customer_item);
		topDelinquentCustomerButton.setImageResource(R.drawable.gd_action_bar_all_friends);
		topDelinquentCustomerButton.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent intent = new Intent(getActivity(), TopDelinquentCustomerActivity.class);
				if (intent != null) {
					startActivity(intent);
				}
			}

		});

		collectorButton = (ImageButton) getActivity().findViewById(R.id.collector_item);
		collectorButton.setImageResource(R.drawable.gd_action_bar_group);
//		collectorButton.setOnClickListener(new CollectorPopupWindowListener(getActivity()));

		profileButton = (ImageButton) getActivity().findViewById(R.id.profile_item);
		profileButton.setImageResource(R.drawable.gd_action_bar_gallery);

		profileButton.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent intent = new Intent(getActivity(), ListOfValueActivity.class);
				if (intent != null) {
					startActivity(intent);
				}
			}

		});

		helpButton = (ImageButton) getActivity().findViewById(R.id.help_item);
		helpButton.setImageResource(R.drawable.gd_action_bar_compose);
		helpButton.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent intent = new Intent(getActivity(), ListOfValueActivity.class);
				if (intent != null) {
					startActivity(intent);
				}
			}

		});
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		return inflater.inflate(R.layout.menu_bar, container, false);
	}

}
